    /* upload img start*/
    $.fn.resizeImage = function (obj) {
             var file = obj.that.files[0];
             var URL = window.URL || window.webkitURL;
             var blob = URL.createObjectURL(file);
             var base64;
             
             var img = new Image();
             img.src = blob;

             if(obj.maxsize){
                 var maxsize = obj.maxsize*1024*1024;
             }else{
                 var maxsize = 2*1024*1024;//允许上传的最大值 2M
                 obj.maxsize = 2;
             }
             
             
             if(!/image\/\w+/.test(obj.that.files[0].type)){
              $.updateAlert("请上传图片！", 'alert-error');
              return false;
             }
        img.onload = function() {
                if(file.size > maxsize){
                      $.updateAlert('图片的大小不能超过'+obj.maxsize+"M", 'alert-error');
                      return false;
                }
              var that = this;

              //生成比例
              var w,scale,h = that.height;
              scale = that.width / that.height;
              if(obj.cutWid == ''){
              w = that.width;
              }else{
              w = obj.cutWid;
              }
              h = w / scale;

              //生成canvas
              var canvas = document.createElement('canvas');
              var ctx = canvas.getContext('2d');
              $(canvas).attr({
              width: w,
              height: h
              });
              ctx.drawImage(that, 0, 0, w, h);
              base64 = canvas.toDataURL('image/jpeg', obj.quality || 0.6);
              var result = {
              base64:base64,
              filename:file.name
              };
              //成功后的回调
              obj.success(result);
        };
    };
    /* upload img end*/


    //上传多张图片
    function uploadImg() {
        var img_arr = new Array();
        //上传图片
        $(document).on("change", ".other_inputFile", function() {
        //$('#other_inputFile').on('change', function() {
            var that=$(this);
            img_arr =that.parent('.img-list').siblings('.u-list');
            $(this).resizeImage({
                that: this,
                cutWid: '',
                quality: 0.8,
                limitWid: '',
                success: function(data) {
                    if (img_arr.length >= 5) {
                        $.confirm("提示", "最多上传5张");
                        $('body').css('padding-right', '0');
                        return false;
                    };

                    var len = $('.img-list').find('img').size();
                    img_arr[len] = data.base64;
                    var img = '<div class="upload-head-img pr tc fl img-list u-list">' +
                        '<img src="' + img_arr[len] + '" width="160" height="120">' +
                        '<span class="zi-changeImg">更换作品</span>'+
                        '<input type="file" class="inputClass changeImg cp"  name="upload-file" />'+
                         '<span class="delete-ico font-s24 icon-icon_del del-icon" data-sid="' + len + '" id="other_img_' + len + '"></span>' +
                        '</div>';

                    that.parent('.img-list-up').before(img);
                }
            });
            var showAddimg=that.parent('.img-list').siblings('.u-list').length;
            if (showAddimg >= 4) {
                that.parent(".img-list-up").css('display', 'none');
            }

            this.value = '';
        });

        //删除相关图片
        $(document).on('click', '.delete-ico', function() {
            var that= $(this);
            var sid = that.attr('data-sid');
            img_arr.splice(sid, 1);
            var showAddimg = that.parent(".img-list").siblings('.u-list').length;
            
            if (showAddimg <5) {
                that.parent(".u-list").siblings('.img-list-up').css('display', 'block');
                that.parent().remove();
            }
        });
        return img_arr;
    }



    $(document).on('change','.changeImg', function(){
      var imgAttr=$(this).siblings('img');
            $(this).resizeImage({
                that: this,
                cutWid: '',
                quality: 0.8,
                limitWid: '',
                success: function(data) {    
                  imgAttr.attr('src', data.base64);
                }
            });
            this.value = '';
    })